package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ExpCharacter;
import com.ruoyi.system.service.IExpCharacterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学员信息Controller
 * 
 * @author 马坚
 * @date 2023-06-20
 */
@RestController
@RequestMapping("/system/exp_character")
public class ExpCharacterController extends BaseController
{
    @Autowired
    private IExpCharacterService expCharacterService;

    /**
     * 查询学员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:exp_character:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpCharacter expCharacter)
    {
        startPage();
        List<ExpCharacter> list = expCharacterService.selectExpCharacterList(expCharacter);
        return getDataTable(list);
    }

    /**
     * 导出学员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:exp_character:export')")
    @Log(title = "学员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpCharacter expCharacter)
    {
        List<ExpCharacter> list = expCharacterService.selectExpCharacterList(expCharacter);
        ExcelUtil<ExpCharacter> util = new ExcelUtil<ExpCharacter>(ExpCharacter.class);
        util.exportExcel(response, list, "学员信息数据");
    }

    /**
     * 获取学员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_character:query')")
    @GetMapping(value = "/{chaID}")
    public AjaxResult getInfo(@PathVariable("chaID") String chaID)
    {
        return success(expCharacterService.selectExpCharacterByChaID(chaID));
    }

    /**
     * 新增学员信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_character:add')")
    @Log(title = "学员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpCharacter expCharacter)
    {
        return toAjax(expCharacterService.insertExpCharacter(expCharacter));
    }

    /**
     * 修改学员信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_character:edit')")
    @Log(title = "学员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpCharacter expCharacter)
    {
        return toAjax(expCharacterService.updateExpCharacter(expCharacter));
    }

    /**
     * 删除学员信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_character:remove')")
    @Log(title = "学员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chaIDs}")
    public AjaxResult remove(@PathVariable String[] chaIDs)
    {
        return toAjax(expCharacterService.deleteExpCharacterByChaIDs(chaIDs));
    }
}
